# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：image_compose.py
#日期：2022-09-11
#备注：通过PIL库处理拼接图片 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

from PIL import Image

# 拼接图片（）
def add_image(base,file):
    img = Image.open(base)
    x0, y0 = img.size
    im= img.resize((2000, int(2000 / x0 * y0)), Image.ANTIALIAS)
    im.save('E:\图片\证件\\户主1.jpeg',quality=100)     # 默认保存质量为quality=75
    #img.show()
    out = Image.open(file)
    x1, y1 = out.size
    im1= out.resize((2000, int(2000 / x1 * y1)), Image.ANTIALIAS)

    image=Image.new("RGB",(2000,int(2000 / x0 * y0)+int(2000 / x1 * y1)))
    image.paste(im,(0,0))
    image.paste(im1,(0,int(2000 / x0 * y0)))
    #image.show()
    image.save('E:\图片\证件\\out.jpeg',quality=100)      # 图片质量100不压缩

if __name__ == '__main__':
    add_image('E:\图片\证件\\户主.jpeg','E:\图片\证件\\曾舒妍-户口.jpeg')